package org.jtb.flickrportlet;

public class AlertHandler {
    private String infoSummary = null;
    private String errorSummary = null;
    private String infoDetail = null;
    private String errorDetail = null;
    
    private boolean infoRendered = false;
    private boolean errorRendered = false;    
    
    public String getInfoSummary() {
        String s = infoSummary;
        return s;
    }
    
    public String getInfoDetail() {
        String s = infoDetail;
        return s;
    }
    
    public void setInfo(String infoSummary) {
        infoRendered = true;
        this.infoSummary = infoSummary;
        this.infoDetail = null;
    }
    
    public void setInfo(String infoSummary, String infoDetail) {
        infoRendered = true;
        this.infoSummary = infoSummary;
        this.infoDetail = infoDetail;
    }
    
    public void setInfo(String infoSummary, Throwable t) {
        infoRendered = true;        
        this.infoSummary = infoSummary;
        this.infoDetail = t.getMessage();
    }
    
    public String getErrorSummary() {
        String s = errorSummary;
        return s;
    }    
    
    public String getErrorDetail() {
        String s = errorDetail;
        return s;
    }
    
    public void setError(String errorSummary) {
        errorRendered = true;        
        this.errorSummary = errorSummary;
        this.errorDetail = null;        
    }
    
    public void setError(String errorSummary, String errorDetail) {
        errorRendered = true;        
        this.errorSummary = errorSummary;
        this.errorDetail = errorDetail;
    }
    
    public void setError(String errorSummary, Throwable t) {
        errorRendered = true;        
        this.errorSummary = errorSummary;
        this.errorDetail = t.getMessage();
    }
    
    
    public boolean isInfoRendered() {
        boolean r = infoRendered;
        if (infoRendered) {
            infoRendered = false;
        }
        return r;
    }
    
    public boolean isErrorRendered() {
        boolean r = errorRendered;
        if (errorRendered) {
            errorRendered = false;
        }
        return r;
    }
    
    public boolean isErrorExists() {
        return errorRendered;
    }
}
